package cn.dujc.superkid.wxapi;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;

import com.tencent.mm.opensdk.constants.ConstantsAPI;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

import cn.dujc.core.util.ToastUtil;
import cn.dujc.superkid.R;
import cn.dujc.superkid.activities.VipActivity;


public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {
 
    private IWXAPI api;
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_pay_result);
    	api = WXAPIFactory.createWXAPI(this,"wxfa28fbde69421b59");
    	api.registerApp("wxfa28fbde69421b59");
        api.handleIntent(getIntent(), this);
    }
 
	@Override
	protected void onNewIntent(Intent intent) {
		super.onNewIntent(intent);
		setIntent(intent);
        api.handleIntent(intent, this);
	}
	@Override
	public void onReq(BaseReq req) {

	}
	@Override
	public void onResp(BaseResp resp) {
		if (resp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {
			sendBroadcast(new Intent("WxPaySuccess"));
//			startActivity(new Intent(this, VipActivity.class));
			finish();
		}else{
			ToastUtil.showToast(this,resp.errStr);
		}
	}
}

